package edu.java.lectures.lec14.collections.usage;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

public class SetTest {
    private static final String LINE = "-----------------------";

    public static void main(String[] args) {
	System.out.println(LINE);
	Set<String> myStrSet = new HashSet<String>();

	String pencho = "pencho";
	String Pencho = "Pencho";
	myStrSet.add(Pencho);
	myStrSet.add("Mincho");
	myStrSet.add("ala");
	myStrSet.add("bala");

	System.out.println(myStrSet);

	System.out.println(myStrSet.add(Pencho));
	System.out.println(myStrSet);
	myStrSet.add(pencho);
	System.out.println(myStrSet);
	System.out.println(pencho.equals(Pencho));
	System.out.println(pencho.hashCode() == Pencho.hashCode());
	System.out.println("Adding pencho again: " + myStrSet.add(pencho));
	Iterator<String> myStrSetIter = myStrSet.iterator();
	while (myStrSetIter.hasNext()) {
	    System.out.println(myStrSetIter.next());
	}
	System.out.println(LINE);
	System.out.println(myStrSet.isEmpty());
	myStrSet.clear();
	System.out.println(myStrSet);
	System.out.println(myStrSet.isEmpty());

	System.out.println(LINE);
	Set<String> myOrderedSet = new LinkedHashSet<String>();
	myOrderedSet.add("ala");
	myOrderedSet.add("bala");
	myOrderedSet.add("nica");
	myOrderedSet.add("turska");
	myOrderedSet.add("panica");

	Iterator<String> myOrderedSetIter = myOrderedSet.iterator();
	while (myOrderedSetIter.hasNext()) {
	    System.out.println(myOrderedSetIter.next());
	}

	System.out.println(LINE);

    }
}
